$().ready(function () {
    $('.summernote').summernote({
        height : '220px',
        lang : 'zh-CN',
        callbacks: {
            onImageUpload: function(files, editor, $editable) {
                sendFile(files);
            }
        }
    });

    var projectid = getQueryString("projectid");
    var projectname = getQueryString("projectname");
    console.log(projectname);
    console.log(projectid);
    $("#projectname").val(projectname);
    $("#projectid").val(projectid);
    //projectid=5508083F32C24BBE84C3997A5D4F4FB0&projectname=非道路小程序

    set_dictinoray_list_to_select("bugstatus", null, "1", "BUGSTATUS", true);//缺陷状态

    set_dictinoray_list_to_select("bugpriortity", null, null, "BUGPRIORTITY", true);//缺陷优先级
    set_dictinoray_list_to_select("bugtype", null, null, "BUGTYPE", true);//缺陷类型
    set_dictinoray_list_to_select("buglevel", null, null, "BUGLEVEL", true);//缺陷等级


    validateRule();
});

$.validator.setDefaults({
    submitHandler: function () {
        save();
    }
});

function save() {

    var content_sn = $("#content_sn").summernote('code');
    $("#bugcontent").val(content_sn);
    $.ajax({
        cache: true,
        type: "POST",
        url: ctx + "/bug/questionInfo/save",
        data: $('#signupForm').serialize(),// 你的formid
        async: false,
        error: function (request) {
            parent.layer.alert("Connection error");
        },
        success: function (data) {
            if (data.code == 0) {
                 layer.msg("操作成功");


            } else {
                 layer.alert(data.msg)
            }

        }
    });

}

function validateRule() {
    var icon = "<i class='fa fa-times-circle'></i> ";
    $("#signupForm").validate({
        rules: {
            name: {
                required: true
            }
        },
        messages: {
            name: {
                required: icon + "请输入姓名"
            }
        }
    })
}